package com.snapan.sync;

import com.snapan.service.ShareService;
import com.snapan.service.UserFileService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 一次性工具：将 user_file + file_base 历史数据同步到 ES（仅运行一次）
 */
public class UserFileToEsSyncTool {
    public static void main(String[] args) {
        // 加载 SSM 配置文件
        ApplicationContext context = new ClassPathXmlApplicationContext(
                "classpath:applicationContext.xml"
        );

        // 获取 UserFileService，执行同步
        UserFileService userFileService = context.getBean(UserFileService.class);
        userFileService.syncAllValidUserFileToEs();

        ShareService shareService = context.getBean(ShareService.class);
        shareService.syncAllValidShareFileToEs();

        System.out.println("历史数据同步 ES 工具执行完成！");
        System.exit(0);
    }
}
